package com.codemes.happylist.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author nscoffee
 */
@Component
public class SpringContextutil implements ApplicationContextAware {

    private static ApplicationContext context;


    private SpringContextutil() {
    }

    public static Object getBean(String view) {
        return context.getBean(view);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }

    public static <T> T getBean(String name, Class<T> aClass) {
        return context.getBean(name, aClass);
    }
}
